package com.ktjiaoyu.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

@Configuration
public class WebConfig extends AbstractAnnotationConfigDispatcherServletInitializer implements WebMvcConfigurer {
    //加载spring配置累
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{SpringConfig.class};
    }
    //加载spring mvc的配置类
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{SpringMvcConfig.class};
    }
    //设置spring mvc前端控制器 拦截的路劲
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    //设置启动页为 logo.jsp
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 将根路径"/"映射到"logo.jsp"
        registry.addViewController("/").setViewName("redirect:login.jsp");
    }
}